/**
 * Created by on 2018/5/9.
 */
define(function () {

    var self, vue,
        app = win.app,
        list = [],//经销商
        spmx = {},//商品明细
        COUNTAMOUNT = 0,
        pageParameters
    ;

    var gwaq553Info = app.Module.extend({

        init: function () {
            self = this;
            self._super({
                _readyBefore: function () {
                    pageParameters = app.pageParameters['gwaqinfo_page'].item;
                }
            }, win);
            //上下页面拉动
            mui('.mui-scroll-wrapper').scroll({
                deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
            });
            //经销商明细

        },
        _lazy: function () {
            this._super();
            //获取经销商
            app.ajax({
                xurl: "api/wx/gwaq553/getjxsList",
                loading: true,
                xdata: {
                    GWBHNAME: pageParameters.GWBHNAME
                },
                cb: function (result) {
                    if (result.ok) {
                        vue.list = result.data.data;
                        vue.list.addMap({checked: true});
                    }
                }
            });

            //获取商品明细
            app.ajax({
                xurl: "api/wx/gwaq553/getspmxList",
                loading: true,
                xdata: {
                    GWBKNAME: pageParameters.GWBHNAME,
                    GWBKSEQ2: pageParameters.GWBHSEQ
                },
                cb: function (result) {
                    if (result.ok) {
                        vue.spmx = result.data.data;

                        var count = 0;
                        for (var j = 0; j < vue.spmx.length; j++) {
                            count += (Number(vue.spmx[j].GWBK004) * Number(vue.spmx[j].GWBK003));
                        }
                        vue.COUNTAMOUNT = count;
                    }
                }
            });
        },
        _ready: function () {
            vue = new Vue({
                el: app.getByid(doc, 'gwaq553Info'),
                data: function () {
                    return {
                        info: pageParameters,
                        list: list,
                        spmx: spmx,
                        COUNTAMOUNT: COUNTAMOUNT,
                        selected: true,
                        isActive: false
                    }
                },
                methods: {
                    showJzxx: function () {
                        app.openPage({
                            src: 'gwaq553/gwaq553-jzxx.html',
                            argsKey: 'gwaq553jzxx_page',
                            args: {
                                GWBHNAME: pageParameters.GWBHNAME
                            }
                        });
                    },
                    showGjpgx: function () {
                        app.openPage({
                            src: 'gwaq553/gwaq553-gjpgx.html',
                            argsKey: 'gwaq553gjpgx_page',
                            args: {
                                GWBHNAME: pageParameters.GWBHNAME,
                                GWBHID: pageParameters.GWBHID
                            }
                        });
                    },
                    showBflc: function () {
                        app.openPage({
                            src: 'gwaq553/gwaq553-bflc.html',
                            argsKey: 'gwaq553bflc_page',
                            args: {
                                GWBHNAME: pageParameters.GWBHNAME,
                                GWBHID: pageParameters.GWBHID
                            }
                        });
                    },
                    DealerDro: function () {
                        this.selected = !this.selected;
                        this.isActive = !this.isActive;
                    }
                }
            })
        }
    });

    return new gwaq553Info();

});